package com.rongke.web;

import com.rongke.commons.JsonResp;
import com.rongke.mapper.AboutUsMapper;
import com.rongke.model.AboutUs;
import com.rongke.service.AboutUsService;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigInteger;
import java.util.List;

/**
 * @AboutUsController
 * @关于我们Controller
 * @version : Ver 1.0
 */
@RestController
@RequestMapping(value="/api/aboutUs")
@Transactional
public class AboutUsController {
    private Logger log = Logger.getLogger(this.getClass());
    @Autowired
    private AboutUsService aboutUsService;

    /**
     * @添加关于我们
     * @param aboutUs
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/add", method = RequestMethod.POST)
    public JsonResp addAboutUs(@RequestBody AboutUs aboutUs){
        log.debug("添加关于我们");
        aboutUsService.insert(aboutUs);
        return JsonResp.ok(aboutUs);
    }

    /**
     * @修改关于我们
     * @param aboutUs
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/update", method = RequestMethod.POST)
    public JsonResp updateAboutUs(@RequestBody AboutUs aboutUs){
        log.debug("修改关于我们");
        aboutUsService.updateById(aboutUs);
        return JsonResp.ok(aboutUs);
    }
    /**
     * @根据id查找关于我们
     * @param id
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/selectOne", method = RequestMethod.GET)
    public JsonResp selectAboutUs(Long id){
        log.debug("查找关于我们");
        AboutUs aboutUs = aboutUsService.selectById(id);
        return JsonResp.ok(aboutUs);
    }


}
